%module TestModule

/** signed32 Convert from Python --> C */
%typemap(in) int32_t {
    if (PyInt_Check($input)) {
        $1 = (int32_t) PyInt_AsLong($input);
    } else if (PyLong_Check($input)) {
        $1 = (int32_t) PyLong_AsLong($input);
    } else {
       SWIG_exception_fail(SWIG_ValueError, "unknown integer type");
    }
}
 
/** signed32 Convert from C --> Python */
%typemap(out) int32_t {
    $result = PyInt_FromLong((long)$1);
}

/*%typemap(in) int32_t, uint32_t, int16_t, uint16_t{
$1 = PyInt_AsInt($input);
}*/

%{
#include "test_module.h"
%}

%include "test_module.h"

